﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using _1242026_1242133.DTO;
using _1242026_1242133.DAO;
using _1242026_1242133.BUS;
using System.Windows.Forms;
namespace _1242026_1242133
{
    public partial class frmQuanLyLoaiKhach : Form
    {
        private bool KiemTraNhapLoaiKhach()
        {
            if(txtMaLoaiKhach.Text == "" || txtTenloaiKhach.Text=="" || txtXoaLoaiPhong.Text=="")
            {
                MessageBox.Show("Chưa Nhập Đủ Thông Tin", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return false;
            }
            return true;
        }
        private void LoadDanhSachLoaiKhach()
        {
            LoaiKhachBUS BUS = new LoaiKhachBUS();
            dgLoaiKhach.DataSource = BUS.LoadDanhSachLoaiKhach();
        }
        public frmQuanLyLoaiKhach()
        {
            InitializeComponent();
            LoadDanhSachLoaiKhach();
        }

        private void btThemLoaiPhong_Click(object sender, EventArgs e)
        {
            if (KiemTraNhapLoaiKhach())
            {
                SqlSever sql = new SqlSever();
                LoaiKhachBUS BUS = new LoaiKhachBUS();
                LoaiKhachDTO LoaiKhachDto = new LoaiKhachDTO(txtMaLoaiKhach.Text, txtTenloaiKhach.Text, float.Parse(txtHeSoKhach.Text));
                DataTable data = BUS.ThemLoaiKhach(LoaiKhachDto);
                DataRow dr = data.Rows[0];
                MessageBox.Show(dr["ErrMsg"].ToString(), "Thông Báo");
                LoadDanhSachLoaiKhach();
            }
        }
    }
}
